home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / futils / futils~1 / src / text11s.zoo / text1.1 / config < prev    next >
Encoding:
Text File  |  1991-11-02  |  7.2 KB  |  277 lines

  1. #!/bin/sh
  2. # Guess values for system-dependant variables and create `Makefile'.
  3. # Copyright (C) 1991 Free Software Foundation, Inc.
  4.  
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9.  
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. # Usage: configure [+srcdir=DIR] [+host=HOST] [+gas] [+nfp] [TARGET]
  20. # All args except +srcdir=DIR are ignored.
  21.  
  22. trap 'rm -f conftest conftest.c; exit 1' 1 3 15
  23.  
  24. set +u # Make sure unset variables are ok.
  25.  
  26. # Make sure we don't find the System V /etc/install.
  27. PATH=`echo $PATH|sed '
  28. s,^/etc:,,
  29. s,:/etc$,,
  30. s,:/etc:,:,g'`
  31.  
  32. # A filename unique to this package, relative to the directory that
  33. # configure is in, which we can look for to find out if srcdir is correct.
  34. unique_file=src/fold.c
  35.  
  36. for arg in $*; do
  37.   # Handle +srcdir with a space before the argument.
  38.   if [ x$next_srcdir = xyes ]; then srcdir=$arg; next_srcdir=
  39.   # Handle +host with a space before the argument.
  40.   elif [ x$next_host = xyes ]; then next_host=
  41.   else 
  42.     case $arg in
  43.      -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
  44.     srcdir=`echo $arg | sed 's/[+-]s[a-z]*=//'` ;;
  45.      -srcdir | +srcdir | +srcdi | +srcd | +src | +sr | +s)
  46.     next_srcdir=yes ;;
  47.      -host=* | +host=* | +hos=* | +ho=* | +h=*) ;;
  48.      -host | +host | +hos | +ho | +h)
  49.     next_host=yes ;;
  50.      -gas | +gas | +ga | +g) ;;
  51.      -nfp | +nfp | +nf | +n) ;;
  52.      *) ;;
  53.     esac
  54.   fi
  55. done
  56.  
  57. # Find the source files, if location was not specified.
  58. if [ x$srcdir = x ]; then
  59.   srcdirdefaulted=yes; srcdir=.
  60.   if [ ! -r $unique_file ]; then srcdir=`pwd`/..; fi
  61. fi
  62. if [ $srcdir != . ]; then VPATH='VPATH = $(srcdir)'; fi
  63.  
  64. if [ ! -r $srcdir/$unique_file ]; then
  65.   if [ x$srcdirdefaulted = xyes ]; then
  66.     echo "$0: Can not find sources in \`.' or \`..'." 1>&2
  67.   else
  68.     echo "$0: Can not find sources in \`${srcdir}'." 1>&2
  69.   fi
  70.   exit 1
  71. fi
  72.  
  73. if test "$RANDOM" = "$RANDOM"; then
  74.   # Plain old Bourne shell.
  75.   echo checking for gcc
  76.   test -z "$CC" -a -n "`gcc 2>&1`" && CC="gcc -O"
  77.  
  78.   echo checking for install
  79.   if test -z "$INSTALL" -a -n "`install 2>&1`"; then
  80.     INSTALL="install -c"
  81.     INSTALLDATA="install -c -m 644"
  82.   fi
  83.  
  84.   echo checking for ranlib
  85.   test -z "$RANLIB" -a -n "`ranlib conftest 2>&1`" && RANLIB=ranlib
  86.   rm -f conftest
  87. else
  88.   # ksh, bash or zsh.  ksh and zsh write "command not found" to stderr.
  89.   echo checking for gcc
  90.   test -z "$CC" && type gcc && CC="gcc -O"
  91.  
  92.   echo checking for install
  93.   if test -z "$INSTALL" && type install; then
  94.     INSTALL="install -c"
  95.     INSTALLDATA="install -c -m 644"
  96.   fi
  97.  
  98.   echo checking for ranlib
  99.   test -z "$RANLIB" && type ranlib && RANLIB=ranlib
  100. fi
  101.  
  102. CC=${CC-cc}
  103. INSTALL=${INSTALL-cp}
  104. INSTALLDATA=${INSTALLDATA-cp}
  105. RANLIB=${RANLIB-echo}
  106. INCLUDEDIR=${INCLUDEDIR-/usr/include}
  107.  
  108. rm -f conftest conftest.c
  109. compile="$CC $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1"
  110.  
  111. # Check for various header files.
  112.  
  113. echo checking signal handler return type
  114. grep 'void[     ]*(\*signal[     ]*(' $INCLUDEDIR/signal.h \
  115.   $INCLUDEDIR/sys/signal.h >/dev/null 2>&1 ||
  116.   DEFS="$DEFS -DSIGTYPE=int"
  117.  
  118. echo checking for st_blksize in struct stat
  119. echo "#include <sys/types.h>
  120. #include <sys/stat.h>
  121. main() { struct stat s; exit(0); s.st_blksize; }" > conftest.c
  122. eval $compile
  123. if test -s conftest && ./conftest 2>/dev/null; then :
  124. else
  125.   DEFS="$DEFS -DST_BLKSIZE_MISSING"
  126. fi
  127. rm -f conftest conftest.c
  128.  
  129. echo checking for ANSI C header files
  130. echo "#include <stdlib.h>
  131. #include <string.h>
  132. main() { exit(0); strerror(0); }" > conftest.c
  133. eval $compile
  134. if test -s conftest && ./conftest 2>/dev/null; then
  135.   DEFS="$DEFS -DSTDC_HEADERS"
  136. fi
  137. rm -f conftest conftest.c
  138.  
  139. echo checking for POSIX.1 header files
  140. echo "#include <unistd.h>
  141. main() {
  142. #ifdef _POSIX_VERSION
  143. exit(0);
  144. #else
  145. exit(1);
  146. #endif
  147. }" > conftest.c
  148. eval $compile
  149. if test -s conftest && ./conftest 2>/dev/null; then
  150.   DEFS="$DEFS -DPOSIX"
  151. fi
  152. rm -f conftest conftest.c
  153.  
  154. echo checking for BSD string and memory functions
  155. echo "#include <strings.h>
  156. main() { exit(0); rindex(0, 0); bzero(0, 0); }" > conftest.c
  157. eval $compile
  158. if test -s conftest && ./conftest 2>/dev/null; then :
  159. else
  160.   DEFS="$DEFS -DUSG"
  161.   rm -f conftest conftest.c
  162.   echo checking for working memory.h
  163.   # On ISC you can't include string.h and memory.h at the same time.
  164.   echo "#include <string.h>
  165. #include <memory.h>
  166. main() { exit(0); }" > conftest.c
  167.   eval $compile
  168.   if test -s conftest && ./conftest 2>/dev/null; then :
  169.     else DEFS="$DEFS -DMEMORY_H_MISSING"
  170.   fi
  171. fi
  172. rm -f conftest conftest.c
  173.  
  174. # Check whether various functions exist.
  175.  
  176. # Functions we provide replacements for.
  177. for func in bcopy memchr memcmp stpcpy
  178. do
  179.   echo checking for $func
  180.   echo "main() { exit(0); ${func}(); }" > conftest.c
  181.   eval $compile
  182.   if test -s conftest && ./conftest 2>/dev/null; then :
  183.   else LIBOBJS="$LIBOBJS ${func}.o"
  184.   fi
  185.   rm -f conftest conftest.c
  186. done
  187.  
  188. # Functions whose absence we work around.
  189. for func in vprintf
  190. do
  191.   echo checking for $func
  192.   echo "main() { exit(0); ${func}(); }" > conftest.c
  193.   eval $compile
  194.   if test -s conftest && ./conftest 2>/dev/null; then :
  195.   else DEFS="$DEFS -D`echo $func|tr '[a-z]' '[A-Z]'`_MISSING"
  196.   fi
  197.   rm -f conftest conftest.c
  198. done
  199.  
  200. case "$DEFS" in
  201. *VPRINTF_MISSING*)
  202.   func=_doprnt
  203.   echo checking for $func
  204.   echo "main() { exit(0); ${func}(); }" > conftest.c
  205.   eval $compile
  206.   if test -s conftest && ./conftest 2>/dev/null; then :
  207.   else DEFS="$DEFS -DDOPRNT_MISSING"
  208.   fi
  209.   rm -f conftest conftest.c
  210.   ;;
  211. esac
  212.  
  213. # Check other misc. things.
  214.  
  215. echo checking for unsigned characters
  216. echo 'main() { char c = 255; exit(c < 0); }' > conftest.c
  217. eval $compile
  218. if test -s conftest && ./conftest 2>/dev/null; then
  219.   DEFS="$DEFS -DCHAR_UNSIGNED"
  220. fi
  221. rm -f conftest conftest.c
  222.  
  223. echo checking for Minix
  224. if test -d /usr/include/minix; then
  225.   DEFS="$DEFS -UUSG -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX"
  226. fi
  227.  
  228. echo checking how to get alloca
  229. echo '
  230. #ifdef __GNUC__
  231. #define alloca __builtin_alloca
  232. #else
  233. #ifdef sparc
  234. #include <alloca.h>
  235. #else
  236. #ifdef _AIX
  237.  #pragma alloca
  238. #else
  239. char *alloca ();
  240. #endif
  241. #endif
  242. #endif
  243. main() { char *p = (char *) alloca(1); exit(0); }' > conftest.c
  244. eval $compile
  245. if test -s conftest && ./conftest 2>/dev/null; then :
  246. elif test -d /usr/ucblib; then LIBS="$LIBS -L/usr/ucblib -lucb"
  247. else LIBS="$LIBS -lPW"
  248. fi
  249. rm -f conftest conftest.c
  250.  
  251. trap 'rm -f Makefile lib/Makefile src/Makefile man/Makefile config.status; exit 1' 1 3 15
  252.  
  253. for dir in . lib src man
  254. do
  255.   test -d $dir || mkdir $dir
  256.   echo '# Generated automatically from Makefile.in by configure.' > $dir/Makefile
  257.   sed -e "
  258. s,@srcdir@,$srcdir,
  259. s,@VPATH@,$VPATH,
  260. s,@CC@,$CC,
  261. s,@RANLIB@,$RANLIB,
  262. s,@INSTALL@,$INSTALL,
  263. s,@INSTALLDATA@,$INSTALLDATA,
  264. s,@DEFS@,$DEFS,
  265. s,@LIBS@,$LIBS,
  266. s,@LIBOBJS@,$LIBOBJS,
  267. " $srcdir/$dir/Makefile.in >> $dir/Makefile
  268. done
  269.  
  270. echo "CC = $CC
  271. RANLIB = $RANLIB
  272. INSTALL = $INSTALL
  273. INSTALLDATA = $INSTALLDATA
  274. DEFS = $DEFS
  275. LIBS = $LIBS
  276. LIBOBJS = $LIBOBJS" > config.status
  277.